<template>
    <div>
      <van-field label="用户名" v-model="form.username"/>
      <van-field label="密码" v-model="form.password"/>
      <van-button @click="login">登录</van-button>
    </div>
</template>

<script>
import axios from 'axios'
export default {
  name: "login",
  data(){
    return{
      form:{}
    }
  },
  methods:{
    login(){
      axios({url:'login',method:'post',data:this.form}).then(res=>{
        if(res.data.code==200){
          localStorage.setItem('userid',res.data.userid)
          localStorage.setItem('username',res.data.username)
          localStorage.setItem('token',res.data.token)
          let c = JSON.stringify(res.data.pagelist)
          localStorage.setItem('pagelist',c)
          alert('成功')
        }
      })
    }
  }
}
</script>

<style scoped>

</style>